```
/* 孤独的二进制
   面向对象点灯
*/
// Led.h 
#pragma once

#include <Arduino.h>
class Led {
  private: //self and friends
    byte _pin;

  public:
    Led();
    Led(byte pin_param);
    void setPin(byte pin_param);
    byte getPin() const;
    void on() const;
    void off() const;
    void toggle() const;
};

// Led.cpp
#include "Led.h"

Led::Led()
{
    _pin = 2;
}

Led::Led(byte pin_param)
{
    setPin(pin_param);
}

void Led::setPin(byte pin_param)  {

  if ((pin_param < 40) && (pin_param >= 0)) {
    _pin = pin_param;
    pinMode(_pin, OUTPUT);
  } else {
    _pin = 2;
    Serial.println("invalid pin number, use default pin 2 instead");
  }

}

byte Led::getPin() const {
  return _pin;
}

void Led::on() const {
  digitalWrite(_pin, HIGH);
}

void Led::off() const {
  digitalWrite(_pin, LOW);
}

void Led::toggle() const {
  digitalWrite(_pin, !digitalRead(_pin));
}


// main.cpp 
#include <Arduino.h>
#include "Led.h"

Led ledGreen, ledYellow, ledRed;

void setup() {
  Serial.begin(115200);

  ledGreen.setPin(33);
  ledYellow.setPin(26);
  ledRed.setPin(27);

  //on
  // digitalWrite(33, HIGH);
  ledGreen.on();
  ledYellow.on();
  ledRed.on();
  delay(1000);

  //off
  // digitalWrite(33, LOW);
  ledGreen.off();
  ledYellow.off();
  ledRed.off();
  delay(1000);

  Serial.print(sizeof(ledGreen));
  Serial.println(" Bytes");
}

void loop() {
  //toggle
  //digitalWrite(33,!digitalRead(33));
  ledGreen.toggle();
  ledYellow.toggle();
  ledRed.toggle();
  delay(100);

}
```